//
//  ByViewMineAddressDefaultToggle.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/23.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewAddressDefaultToggle.h"

@implementation ByViewAddressDefaultToggle
{
    UIButton *_toggleButton;
    UILabel *_noteLabel;
}
- (instancetype)init {
    
    if (self = [super init]) {
        
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    _toggleButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_toggleButton setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
    [_toggleButton setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateSelected];
    [self addSubview:_toggleButton];
    
    _noteLabel = [[UILabel alloc] init];
    _noteLabel.adjustsFontSizeToFitWidth = true;
    _noteLabel.text = @"默认地址";
    _noteLabel.font = FONT(14);
    _noteLabel.textAlignment = NSTextAlignmentLeft;
    _noteLabel.textColor = [UIColor blackColor];
    [self addSubview:_noteLabel];
    
    [_toggleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.left.equalTo(self);
        make.centerY.equalTo(self);
    }];
    [_noteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_toggleButton.mas_right).offset(10);
        make.right.equalTo(self);
        make.top.bottom.equalTo(self);
    }];
}
- (void)setIsDefault:(BOOL)isDefault {
    
    _isDefault = isDefault;
    _toggleButton.selected = isDefault;
    _noteLabel.textColor = isDefault ? BY_GOLD_COLOR : [UIColor blackColor];
}


@end
